﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DB_NH.DB_Map.gxjdWebSite
{
    using NHibernate;
    using NHibernate.Mapping.ByCode;
    using NHibernate.Mapping.ByCode.Conformist;
    public class Map_Department : ClassMapping<DB_Model.gxjdWebSite.Department>
    {
        public Map_Department()
        {
            Id(x => x.dept_id, map =>
            {
                map.Length(40);
            });

            Property(x => x.dept_name, map =>
            {
                map.Length(200);
            });

            Property(x => x.dept_code, map =>
            {
                map.Length(200);
            });

            Property(x => x.create_date, map =>
            {
              
            });

            Property(x => x.dept_level, map =>
            {   
            });

            Property(x => x.is_leaf, map =>
            {
             
            });

            Property(x => x.dept_phone, map =>
            {
                map.Length(200);
            });

            Property(x => x.dept_fax, map =>
            {
                map.Length(200);
            });

            Property(x => x.dept_linker, map =>
            {
                map.Length(200);
            });

            Property(x => x.dept_email, map =>
            {
                map.Length(200);
            });

            Property(x => x.dept_path, map =>
            {
                map.Length(255);
            });

            Property(x => x.is_valid, map =>
            {
             
            });

            //上一级分类
            ManyToOne(x => x.pre_department, map =>
            {
                map.Column("pre_dept_id");
                map.NotNullable(false);
                map.Cascade(Cascade.None);
            });

            Bag(x => x.sub_departments, bag =>
            {
                bag.Key(km => km.Column("pre_dept_id"));
                bag.Cascade(Cascade.None);
                bag.Inverse(false);
            }, act => act.OneToMany());

            Table("t_sys_deptartment");
        }
    }
}
